home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / powervww / options.cpp < prev    next >
C/C++ Source or Header  |  1998-01-05  |  47KB  |  1,253 lines

  1. //  ____________________________________________________
  2. // |                                                    |
  3. // |  Project:     POWER VIEW IDE                       |
  4. // |  File:        OPTIONS.CPP                          |
  5. // |  Compiler:    WPP386 (10.6)                        |
  6. // |                                                    |
  7. // |  Subject:     Options Manager implementation       |
  8. // |                                                    |
  9. // |  Author:      Emil Dotchevski                      |
  10. // |____________________________________________________|
  11. //
  12. // E-mail: zajo@geocities.com
  13. // URL:    http://www.geocities.com/SiliconValley/Bay/3577
  14.  
  15. #define uses_stdio
  16. #define uses_string
  17.  
  18. #define uses_app
  19. #define uses_check
  20. #define uses_combo
  21. #define uses_editor
  22. #define uses_hist
  23. #define uses_ht
  24. #define uses_icons
  25. #define uses_input
  26. #define uses_stddlg
  27. #define uses_system
  28. #define uses_table
  29. #define uses_txt
  30.  
  31. #include "PVUSES.H"
  32. #include "W.H"
  33. #include "TLOG.H"
  34. #include "TPROJECT.H"
  35. #include "COMPILE.H"
  36.  
  37. #define _DECLARE_OPTIONS_H
  38.   #include "OPTIONS.H"
  39. #undef  _DECLARE_OPTIONS_H
  40.  
  41.  
  42. /*
  43. STATIC DATA
  44. */
  45.   static char pvo_signature[] = "\r\nPower View IDE options file.\r\n\032";
  46.  
  47.  
  48. #pragma off( unreferenced )
  49.   static Tcombo_box *of_target, *of_calls, *of_cpu, *of_debug, *of_optimize;
  50.   static void options_fast_handler( Titem *p )
  51.   {
  52.     of_optimize->set_state( isDISABLED, (compiler_options.debug_options&doOPTIMIZATIONS) && of_debug->cursor() );
  53.     of_cpu->set_enable( 0, of_target->cursor()<7 );
  54.     of_cpu->set_enable( 1, of_target->cursor()<7 );
  55.     of_cpu->set_enable( 2, of_target->cursor()<7 );
  56.     of_calls->set_enable( 0, of_target->cursor()>6 );
  57.     if( !of_cpu  ->enabled(of_cpu  ->cursor()) ) of_cpu  ->set_data( 5 );
  58.     if( !of_calls->enabled(of_calls->cursor()) ) of_calls->set_data( 1 );
  59.   }
  60. #pragma on( unreferenced )
  61.  
  62. void options_fast( void )
  63. {
  64.   uint cpu=compiler_options.cpu-1,
  65.        calls=compiler_options.calling_conventions-1,
  66.        model=compiler_options.memory_model-1,
  67.        align=compiler_options.alignment-1,
  68.        optimize=(compiler_options.options&opOPTIMIZATIONS)? compiler_options.optimize_for : 0,
  69.        debug=(compiler_options.options&opDEBUG_INFO)? compiler_options.debug_level : 0,
  70.        fp=compiler_options.fp_instructions-1,
  71.        target=linker_options.target_os? linker_options.target_os-1 : 0;
  72.   _help( htD_FAST_OPTIONS );
  73.   dialog( "Fast compiler/linker options" ); hspacing( 4 );
  74.   handler( options_fast_handler );
  75.   of_target = combo_box( "|~Target ", target, 35 );
  76.   for( uint i=1; i<TO_COUNT; i++ )
  77.     of_target->add( target_os[i].title );
  78.   push();
  79.   _combo_lines( 6 );
  80.   of_cpu = combo_box( "C|~PU    ", cpu, 7 );
  81.     of_cpu->add( "8086" );
  82.     of_cpu->add( "80186" );
  83.     of_cpu->add( "80286" );
  84.     of_cpu->add( "80386" );
  85.     of_cpu->add( "80486" );
  86.     of_cpu->add( "Pentium" );
  87.   _combo_lines( 2 );
  88.   of_calls = combo_box( "|~Calls  ", calls, 7 );
  89.     of_calls->add( "Regs" );
  90.     of_calls->add( "Stack" );
  91.   _combo_lines( 5 );
  92.   Tcombo_box *of_model = combo_box( "|~Model  ", model, 7 );
  93.     of_model->add( "Small" );
  94.     of_model->add( "Medium" );
  95.     of_model->add( "Compact" );
  96.     of_model->add( "Large" );
  97.     of_model->add( "Flat" );
  98.   _combo_lines( 4 );
  99.   Tcombo_box *of_align = combo_box( "|~Align  ", align, 7 );
  100.     of_align->add( "Byte" );
  101.     of_align->add( "Word" );
  102.     of_align->add( "Dword" );
  103.     of_align->add( "Qword" );
  104.   nc();
  105.   _combo_lines( 4 );
  106.   of_optimize = combo_box( "|~Optimize", optimize, 10 );
  107.     of_optimize->add( "OFF" );
  108.     of_optimize->add( "Speed" );
  109.     of_optimize->add( "Size" );
  110.     of_optimize->add( "Speed/Size" );
  111.   _combo_lines( 3 );
  112.   of_debug = combo_box( "De|~bug   ", debug, 10 );
  113.     of_debug->add( "OFF" );
  114.     of_debug->add( "Lines" );
  115.     of_debug->add( "Full" );
  116.   _combo_lines( 3 );
  117.   Tcombo_box *of_float = combo_box( "|~FP      ", fp, 10 );
  118.     of_float->add( "Calls" );
  119.     of_float->add( "Emulation" );
  120.     of_float->add( "Inline" );
  121.   linput( "|~Stack   ", linker_options.stack_size, 1024, 0x10000000 );
  122.   pop(); hor(); hspacing( 2 );
  123.   _history( &compiler_options.defines );
  124.   input( "|~Defines", compiler_options.defines, 127, 34 );
  125.   nl();
  126.   cinput( "|~Warnings level", compiler_options.warn_level, 0,   4 );
  127.   hspaces( 4 );
  128.   cinput( "|~Errors limit",   compiler_options.max_errors, 1, 255 );
  129.   nl();
  130.   check( "Warnings a|~re errors",  compiler_options.debug_options, doWARN_IS_ERR );
  131.   check( "Precompiled |~headers", compiler_options.options, opPRECOMPILE );
  132.   options_fast_handler( NULL );
  133.   if( bkch() )
  134.   {
  135.     options_changed = 1;
  136.     compiler_options.code_size = target>6? cs32BITS : cs16BITS;
  137.     linker_options.target_os=++target,
  138.     compiler_options.cpu=++cpu,
  139.     compiler_options.calling_conventions=++calls,
  140.     compiler_options.memory_model=++model,
  141.     compiler_options.alignment=++align,
  142.     compiler_options.fp_instructions=++fp;
  143.     switch( compiler_options.memory_model )
  144.     {
  145.       case mmSMALL:
  146.       case mmMEDIUM:
  147.       case mmFLAT_HUGE:
  148.         compiler_options.ds_segment = dsPEGGED;
  149.         compiler_options.fsgsss_segments = 0;
  150.         break;
  151.       default:
  152.         compiler_options.ds_segment = dsFLOATS;
  153.         compiler_options.fsgsss_segments = ssNEQDGROUP;
  154.         break;
  155.     }
  156.     if( !of_optimize->state( isDISABLED ) )
  157.       if( optimize )
  158.       {
  159.         compiler_options.optimize_for=optimize,
  160.         compiler_options.options|=opOPTIMIZATIONS,
  161.         compiler_options.optimizations|=opLOOP|opREORDER|opCALLRET|opRELAX|opNUMERICALLY|opPENTIUM;
  162.         if( optimize==1 )
  163.           compiler_options.optimizations|=opINLINE|opINTRINSIC;
  164.         else
  165.           compiler_options.optimizations&=~(opINLINE|opINTRINSIC|opUSER);
  166.       }
  167.       else
  168.         compiler_options.options&=~opOPTIMIZATIONS;
  169.     if( debug )
  170.       compiler_options.debug_level=debug,
  171.       compiler_options.options|=opDEBUG_INFO;
  172.     else
  173.       compiler_options.options&=~opDEBUG_INFO;
  174.   }
  175. }
  176.  
  177.  
  178. /*
  179. COMPILER
  180. */
  181.     static Tradio *r16, *r32, *r086, *r186, *r286, *r386, *calls_stack, *calls_regs, *rm_flat;
  182.     static void occg_handler( Titem *p )
  183.     {
  184.       boolean m16 = ( p == r16 );
  185.       boolean m32 = ( p == r32 );
  186.       if( !m16 && !m32 ) return;
  187.       if( m16 )
  188.       {
  189.         calls_stack->press();
  190.         rm_flat->set_prompt( "|~Huge" );
  191.       }
  192.       else
  193.       {
  194.         if( r086->pressed() || r186->pressed() || r286->pressed() ) r386->press();
  195.         rm_flat->set_prompt( "|~Flat" );
  196.       }
  197.       r086->set_state( isDISABLED, m32 );
  198.       r186->set_state( isDISABLED, m32 );
  199.       r286->set_state( isDISABLED, m32 );
  200.       calls_regs->set_state( isDISABLED, m16 );
  201.     }
  202.  
  203.   void options_compiler_code_generation( void )
  204.   {
  205.     _help( htD_CODE_GENERATION );
  206.     dialog( "Code generation" ); handler( occg_handler );
  207.     hspacing( 1 );
  208.     frame( "Memory model" );
  209.                 radio( "|~Small",      compiler_options.memory_model, mmSMALL     );
  210.                 radio( "|~Medium",     compiler_options.memory_model, mmMEDIUM    );
  211.                 radio( "|~Compact   ", compiler_options.memory_model, mmCOMPACT   );
  212.                 radio( "|~Large",      compiler_options.memory_model, mmLARGE     );
  213.       rm_flat = radio( "|~Flat",       compiler_options.memory_model, mmFLAT_HUGE );
  214.     endfr();
  215.     nc();
  216.     frame( "CPU" );
  217.       r086 = radio( "8|~086",      compiler_options.cpu, cp8086  );
  218.       r186 = radio( "80|~186",     compiler_options.cpu, cp80186 );
  219.       r286 = radio( "80|~286",     compiler_options.cpu, cp80286 );
  220.       r386 = radio( "80|~386",     compiler_options.cpu, cp80386 );
  221.              radio( "80|~486",     compiler_options.cpu, cp80486 );
  222.              radio( "|~Pentium  ", compiler_options.cpu, cp80586 );
  223.     endfr();
  224.     nc();
  225.     frame( "Code size" );
  226.       r16 = radio( "1|~6 bit   ", compiler_options.code_size, cs16BITS );
  227.       r32 = radio( "32 b|~it", compiler_options.code_size, cs32BITS );
  228.     endfr();
  229.     frame( "Calls" );
  230.       calls_s